﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Softserve.Pottery.Store.Domains;

namespace Softserve.Pottery.Store
{
    using System;
    using Softserve.Pottery.Infrastructure;
    using Softserve.Pottery.Infrastructure.Interfaces;
    using Softserve.Pottery.Store.Contracts;

    public class StoreController : DomainControllerBase, IStoreScopeContract
    {
        #region Construcors from base();

        public StoreController(IRepository context)
            : base(context) { }

        public StoreController(IRepository context, IMessenger bridge)
            : base(context, bridge, null) { }

        public StoreController(IRepository context, IMessenger bridge, IServiceProvider provider) : base(context, bridge, provider) { }

        #endregion

        protected override void Dispose(bool disposeManaged)
        {
            ///TODO: Implement code of release resources here
        }

        #region ICatalogContract Members

        public IEnumerable<Catalog> GetCatalogs()
        {
            return Storage.Enumerate<Catalog>();
        }

        #endregion

        #region INotificationContract Members

        public Domains.Notification CreateNotification(int id, string receiver, NotificationType notificationType, string message = default(string))
        {
            throw new System.NotImplementedException();
        }

        #endregion

        #region IProductContract Members

        public void AddProduct(Product item)
        {
            throw new System.NotImplementedException();
        }

        public void EditProduct(Product item)
        {
            throw new NotImplementedException();
        }

        public void RemoveProduct(Product item)
        {
            throw new System.NotImplementedException();
        }

        public Product GetProductById(int productId)
        {
            IEnumerable<Product> products = Storage.Enumerate<Product>();

            var result = (from product in products
                         where product.Id == productId
                         select product).SingleOrDefault();

            return result;
        }

        public IEnumerable<Product> GetProducts()
        {
           return Storage.Enumerate<Product>();
        }

        public IEnumerable<Product> GetProductsByCatalogId(int catalogId)
        {
            IEnumerable<Product> products = Storage.Enumerate<Product>();

            var result = from product in products
                         where product.CatalogId == catalogId
                         select product;

            return result;
        }

        #endregion

        #region IUserContract Members

        public Domains.User UserCreation(int id, string partnerCardNumber, decimal cumulativeSum, int status, System.DateTime dateCreate, string firstName, string lastName, string middleName, string email, string phoneNumber, UserGroup Group)
        {
            throw new System.NotImplementedException();
        }

        #endregion
    }
}
